<?php

	function db_connect($db_server,$db_user,$db_pass,$db_name) {
		$conn = mysql_connect($db_server,$db_user,$db_pass);
		if (!$conn) return 0;
		mysql_select_db($db_name);
		return $conn;
	}

	function random_code ($size) {
		$c1 = array('b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'z', 'd', 'f', 'l', 'm', 'n', 'p', 'r', 's', 't');
		$c2 = array('a', 'a', 'a', 'e', 'e', 'e', 'i', 'i', 'o', 'o', 'u', 'u', 'y');
		$code = "";
		//generation du code
		for ($i=1;$i<=$size;$i++) {
			$rand = rand(0,2);
			switch ($rand) {
				case 2 : $code .= rand(0,9); break;
				default: $code .= ($i%2==0)?$c1[rand(0, count($c1)-1)]:$c2[rand(0, count($c2)-1)];
			}
		}
		return $code;
	}



?>
